feat/path conversions#2827
Conversation
Signed-off-by: Vincent Biret <vibiret@microsoft.com>
Signed-off-by: Vincent Biret <vibiret@microsoft.com>
Signed-off-by: Vincent Biret <vibiret@microsoft.com>
Signed-off-by: Vincent Biret <vibiret@microsoft.com>
…where finding Agent-Logs-Url: https://github.com/microsoft/OpenAPI.NET/sessions/4f39d2a9-62e7-497f-be81-7f0efcb876c9 Co-authored-by: baywet <7905502+baywet@users.noreply.github.com>
…ce and rename V3_0 to V30 Agent-Logs-Url: https://github.com/microsoft/OpenAPI.NET/sessions/0fac65d3-0bbb-44db-b82e-7648c8fb8f86 Co-authored-by: baywet <7905502+baywet@users.noreply.github.com>
|
@copilot we're missing a policy to map the requestBody property to a in:body parameter for the path conversion to v2 |
…sion Agent-Logs-Url: https://github.com/microsoft/OpenAPI.NET/sessions/3e249ace-8d41-41c9-af08-288d036a4def Co-authored-by: baywet <7905502+baywet@users.noreply.github.com>
Added in c0d89d1. The new
|
|
@copilot the policies aren't 'rooted' in the document then they can have false positive matches. For example the V2ResponseContentUnwrappingPolicy can match an extension or schema that just happens to have a path that matches ./responses/[^/]/content/[^/]*. Example paths that can cause incorrect path conversions: #/paths/ Attempt to root the regexes where possible (dollar sign), add additional negative tests |
… in schema trees Agent-Logs-Url: https://github.com/microsoft/OpenAPI.NET/sessions/ade1e55d-3bd6-4d67-baee-32d89b1ad9f9 Co-authored-by: baywet <7905502+baywet@users.noreply.github.com>
Addressed in c063087. Two rooting strategies were applied:
Added negative tests covering schema-property false positives, extension-path false positives, and component-schema paths where only the rename applies. |
|
There was a problem hiding this comment.
Pull request overview
Adds an experimental path/pointer conversion helper so JSON Pointer paths produced by the v3-based walker/validator can be translated to equivalent pointers for older specs (notably OpenAPI v2), addressing issue #2806’s incorrect pointer output for v2 inputs.
Changes:
- Introduces
OpenApiPathHelperwith pluggable policies to transform or null-out pointers for unsupported constructs by target spec version. - Adds
OpenApiValidatorError.GetVersionedPointer(...)as a convenience API for converting validation error pointers. - Adds comprehensive unit tests and new documentation for experimental API usage, including an
ExperimentalAttributepolyfill for non-.NET8 targets.
Reviewed changes
Copilot reviewed 7 out of 7 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
| test/Microsoft.OpenApi.Tests/Services/OpenApiPathHelperTests.cs | Adds coverage for v2/v3 pointer conversion behaviors and edge cases. |
| src/Microsoft.OpenApi/Validations/OpenApiValidatorError.cs | Adds experimental GetVersionedPointer convenience method. |
| src/Microsoft.OpenApi/Services/OpenApiPathHelper.cs | Implements path conversion logic via spec-targeted policies. |
| src/Microsoft.OpenApi/Services/IOpenApiPathRepresentationPolicy.cs | Introduces internal policy interface for conversions. |
| src/Microsoft.OpenApi/PublicAPI.Unshipped.txt | Declares new public APIs for PublicAPI analyzer. |
| src/Microsoft.OpenApi/Attributes/ExperimentalAttribute.cs | Provides non-.NET8 polyfill for ExperimentalAttribute. |
| docs/experimental-apis.md | Documents experimental API diagnostics and the new path conversion APIs. |
| // Walk through segments looking for v3-only constructs | ||
| for (var i = 1; i < segments.Length; i++) | ||
| { | ||
| var segment = segments[i]; | ||
|
|
||
| // Skip segments that are inside a schema property tree — they are property names, | ||
| // not structural OpenAPI keywords. | ||
| if (OpenApiPathHelper.IsSchemaContext(segments, i)) | ||
| { | ||
| continue; | ||
| } | ||
|
|
||
| // servers, callbacks, links at any nested level | ||
| if (UnsupportedSegments.Contains(segment)) | ||
| { | ||
| return true; | ||
| } |
There was a problem hiding this comment.
V2UnsupportedPathPolicy treats servers/callbacks/links segments as unsupported at any nested level (outside schema properties). For pointers that traverse extension payloads (e.g., #/x-foo/servers/0), this will return null even though extensions are version-agnostic and the path should typically be left unchanged. Consider adding an “extension context” guard (similar to IsSchemaContext) that disables v2 structural keyword handling after any segment starting with x- (OpenApiConstants.ExtensionFieldNamePrefix).
…dd to transformations table Agent-Logs-Url: https://github.com/microsoft/OpenAPI.NET/sessions/f2c0015f-dd1e-488a-a10f-1eaecad56cbe Co-authored-by: baywet <7905502+baywet@users.noreply.github.com>
|



fixes #2806